<template>

	<view class="zi-liao-container" style="position: relative;">

		<myLoading v-if="isLoading"></myLoading>

		<template v-else>
			<!-- <view style="height:55rpx;"></view> -->
<!-- 			<view :style="'height:' + statusBarHeight + 'px;'"></view> -->
			<image style="width: 100%;" src="../../static/11.jpg" mode="widthFix"></image>
			<view @click="goBack" style="width: 90rpx;height: 155rpx;position: absolute;left: 0;top: 55rpx;"></view>
			<view @click="geZiliao" style="width: 190rpx;height: 50px;position: absolute;right: 0;top: 85rpx;"></view>






			<view style="width:110rpx;height:110rpx;background-color: rgba(255, 255, 255, 0.8);
			border-radius: 100%;position: absolute;left: 50rpx;top: 263rpx;">
				<image style="width: 110rpx;height: 110rpx;border-radius: 100%;" :src="formData.avatar">

				</image>
			</view>

			<view class="zhanwe"
				style="width: 117rpx;height: 50rpx;margin-left: 8rpx;display: flex;justify-content: center;align-items: center;font-size: 38rpx;font-weight: 700;position: absolute;top: 273rpx;left: 174rpx;">
				{{ formData.name }}
			</view>

			<!-- +55 -->
			<view
				style="background-color: #e1f5fc;width: 50rpx;height: 50rpx;position: absolute;top: 321rpx;left: 322rpx;font-weight: 400;font-size: 30rpx;color: #6d838e;">
				{{ formData.dayNum }}
			</view>

		</template>



	</view>
</template>

<script>
export default {
	data() {
		return {
			// 可以在这里添加数据
			formData: {
				name: '',
				phone: '',
				idCard: '',
				firstReceiveDate: '',
				avatar: ''
			},
			isLoading: true
		}
	},
	onShow() {
		// 页面加载时，尝试从本地缓存获取数据
		this.loadUserData();

	},
	onLoad() {
		// 定义一个0.3-1的随机数
		let randomNum = Math.random() * 0.7 + 0.3;
		// 转换为毫秒
		let randomDelay = randomNum * 1000;
		// 延迟执行
		setTimeout(() => {
			setTimeout(() => {
				this.isLoading = false
			}, randomDelay)
		})
	},
	created() {
		this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight
	},
	methods: {
		loadUserData() {
			const userData = uni.getStorageSync('userInfo');
			console.log('从本地存储获取的数据:', userData);
			if (userData) {
				const parsedData = JSON.parse(userData);
				console.log('成功加载本地存储的数据:', parsedData);
				this.formData = parsedData;
				console.log('成功加载到formData:', this.formData);
			}
		},
		goBack() {
			uni.navigateBack();
		},
		geZiliao() {
			uni.navigateTo({
				url: '/pages/ziLiao/ziLiao'
			})
		}
	}
}
</script>

<style scoped>
.zhanwe {
	/* 		background-image: linear-gradient(to bottom, rgba(255, 223, 202, 0.8), rgba(243, 234, 225, 0)); */
	background-color: #e3f5f7;
}
</style>
